package com.xy.smartsms.facade;

import com.xy.smartsms.manager.PublicInfoManager;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import cn.com.xy.sms.sdk.action.AbsSdkDoAction;

/**
 * Created by admin on 2017/3/9.
 */

public abstract class AbsFacadeDoAction extends AbsSdkDoAction {
    /**
     * 默认，即客户不设置
     */
    public static final int SWITCH_NA = -1;
    /**
     * 仅运营商
     */
    public static final int SWITCH_CARRIER = 1;
    /**
     * 仅小源
     */
    public static final int SWITCH_XIAOYUAN = 2;
    /**
     * 融合
     */
    public static final int SWITCH_COMBINE = 3;

    /**
     * sdk的事件类型处理
     *
     * @param eventType
     * @param extend
     */
    @Override
    public void onEventCallback(int eventType, Map<String, Object> extend) {
        switch (eventType) {
            case SDK_EVENT_LOAD_COMPLETE:
                // 预识别
                SmsProcessFacade.getInstance().backgroundParse(null, 200);
                break;

            case SDK_EVENT_REMOVE_PUBINFO_CACHE:
                if (PublicInfoManager.getInstance() != null && extend != null) {
                    List<String> phoneList = (ArrayList<String>) extend.get("nums");
                    PublicInfoManager.getInstance().updatePhonePublicIdDataCache(phoneList);
                }
                break;

        }
    }

    /**
     * 根据短信接收时间获取号码对应的短信列表
     *
     * @param phone            接入号码
     * @param startReceiveTime 起始接收时间
     * @param endReceiveTime   结束接收时间
     * @param limit            短信条数
     * @return 短信数据列表，包含的key值有："msgId","phone","msg","centerNum","smsReceiveTime"
     */
    @Override
    public List<JSONObject> getReceiveMsgByReceiveTime(
            String phone,
            long startReceiveTime,
            long endReceiveTime,
            int limit) {
        return null;
    }

    /**
     * 获取设备型号sim卡对应的运营商
     *
     * @param simIndex -1:当前手机默认卡位; 0:卡1; 1:卡2
     * @param iccid
     * @return OPERATOR_UNKNOWN:未知, OPERATOR_CMCC:中移, OPERATOR_CUCC:中国联通, OPERATOR_CTCC:中国电信
     * @note 菜单识别的时候simIndex==-1 iccid==null
     */
    @Override
    public int getModelOperator(int simIndex, String iccid) {
        return OPERATOR_CMCC;
    }

    /**
     * 获取客户定制控制开关
     *
     * @return
     */
    public int customTopSwitch() {
        return SWITCH_NA;
    }
}
